<?php
// MailNotification 0.5 index.php
// Author: Tim (http://diary.tw/tim)
// Modify for TC 1.6: Hina (http://hina.ushiisland.net/blog/)

function AddingComment($target, $mother)
{
	global $owner, $hostURL, $blogURL, $database, $service, $configVal;
	requireComponent('TextCube.Function.misc');

	$type = 1; // comment
	if ($mother['entry'] == 0) $type = 3; // guestbook
	$langMsg = array();
	switch(getBlogSetting('language')) {
		case "zh-TW":
			$langMsg['There is a new'] = "您有一封新";
			$langMsg['secret'] = "秘密";
			$langMsg['comment'] = "回覆";
			$langMsg['guestbook'] = "留言";
			$langMsg['subject'] = "您有一則新訊息";
			$langMsg['name'] = "暱稱";
			$langMsg['content'] = "內容";
			$langMsg['link'] = "查看網址";
		break;
		case "zh-CN":
			$langMsg['There is a new'] = "您有一封新";
			$langMsg['secret'] = "秘密";
			$langMsg['comment'] = "回复";
			$langMsg['guestbook'] = "留言";
			$langMsg['subject'] = "您有一则新讯息";
			$langMsg['name'] = "昵称";
			$langMsg['content'] = "内容";
			$langMsg['link'] = "查看网址";
		break;
		default:
			$langMsg['There is a new'] = "There is a new";
			$langMsg['secret'] = "secret";
			$langMsg['comment'] = "comment";
			$langMsg['guestbook'] = "comment";
			$langMsg['subject'] = "You have a new message";
			$langMsg['name'] = "Name";
			$langMsg['content'] = "Content";
			$langMsg['link'] = "Please visit";
	}
	// get the email of this owner
	$loginid = DBQuery::queryCell("SELECT `loginid` FROM {$database['prefix']}Users WHERE `userid` = $owner");

	$message = $langMsg['There is a new'];
	$message .= ($mother['secret'] ==  true) ? $langMsg['secret'] : "";

	if ($type==1)
	{
		$message .= " ".$langMsg['comment']."<br /><br />\n";
		$ulink = "$hostURL$blogURL/{$mother['entry']}";
	}
	else if ($type==3)
	{
		$message .= " ".$langMsg['guestbook']."<br /><br />\n";
		$ulink = "$hostURL$blogURL/guestbook";
	}
	$message .= $langMsg['name'].": {$mother['name']} ({$mother['ip']})<br />\n";
	$message .= $langMsg['content'].": <br />\n{$mother['comment']}<br /><br />\n";
	$message .= $langMsg['link'].": <a href='$ulink'>$ulink</a>";

	// for TextCube 1.6: sendEmail($senderName, $senderEmail, $name, $email, $subject, $message )
	sendEmail("TextCube Blog", "noreply@".$service['domain'], "MailNotification", $loginid,$langMsg['subject'],$message);

	// do not effect the original return;
	return $target && true;
}
?>